package vista;
import java.awt.BorderLayout;
import java.awt.LayoutManager;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaConsultarRegalosObsequiados extends javax.swing.JFrame {
	private JPanel jpContenedorConsultarRegalosObsequiados;
	private JLabel lblConsultarRegalosObsequiados;
	private JButton cmdLimpiarConsulta;
	private JTable tblListaObsequios;
	private JScrollPane scpListadoObsequios;
	private JButton cmdBuscarConsulta;
	private JButton cmdSalirConsulta;
	private JTextField txtCodigoConsulta;
	private JLabel lblCodigoConsulta;
	private LayoutManager jpContenedorConsultarRegalosObsequiadosLayout;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				VentanaConsultarRegalosObsequiados inst = new VentanaConsultarRegalosObsequiados();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public VentanaConsultarRegalosObsequiados() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Consultar Regalos Obsequiados");
			{
				jpContenedorConsultarRegalosObsequiados = new JPanel();
				getContentPane().add(jpContenedorConsultarRegalosObsequiados, BorderLayout.CENTER);
				jpContenedorConsultarRegalosObsequiados.setLayout(null);
				{
					lblConsultarRegalosObsequiados = new JLabel();
					jpContenedorConsultarRegalosObsequiados.add(lblConsultarRegalosObsequiados);
					lblConsultarRegalosObsequiados.setText("Regalos Obsequiados");
					lblConsultarRegalosObsequiados.setBounds(240, 21, 199, 15);
				}
				{
					lblCodigoConsulta = new JLabel();
					jpContenedorConsultarRegalosObsequiados.add(lblCodigoConsulta);
					lblCodigoConsulta.setText("Codigo:");
					lblCodigoConsulta.setBounds(43, 69, 76, 15);
				}
				{
					txtCodigoConsulta = new JTextField();
					jpContenedorConsultarRegalosObsequiados.add(txtCodigoConsulta);
					txtCodigoConsulta.setBounds(110, 69, 93, 22);
				}
				{
					cmdSalirConsulta = new JButton();
					jpContenedorConsultarRegalosObsequiados.add(cmdSalirConsulta);
					cmdSalirConsulta.setText("Salir");
					cmdSalirConsulta.setBounds(557, 18, 72, 22);
				}
				{
					cmdBuscarConsulta = new JButton();
					jpContenedorConsultarRegalosObsequiados.add(cmdBuscarConsulta);
					cmdBuscarConsulta.setText("Buscar");
					cmdBuscarConsulta.setBounds(225, 69, 91, 22);
				}
				{
					scpListadoObsequios = new JScrollPane();
					jpContenedorConsultarRegalosObsequiados.add(scpListadoObsequios);
					scpListadoObsequios.setBounds(33, 118, 595, 235);
					{
						TableModel tblListaObsequiosModel = 
								new DefaultTableModel(
										new String[][] { { }, { } },
										new String[] { });
						tblListaObsequios = new JTable();
						scpListadoObsequios.setViewportView(tblListaObsequios);
						tblListaObsequios.setModel(tblListaObsequiosModel);
					}
				}
				{
					cmdLimpiarConsulta = new JButton();
					jpContenedorConsultarRegalosObsequiados.add(cmdLimpiarConsulta);
					cmdLimpiarConsulta.setText("Limpiar");
					cmdLimpiarConsulta.setBounds(332, 69, 91, 22);
				}
				jpContenedorConsultarRegalosObsequiados.setLayout(jpContenedorConsultarRegalosObsequiadosLayout);
			}
			pack();
			this.setSize(650, 415);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	public void agregarListener(ActionListener accion){
		this.cmdBuscarConsulta.addActionListener(accion);

		this.cmdLimpiarConsulta.addActionListener(accion);

		this.cmdSalirConsulta.addActionListener(accion);
	}
	
	public String getTxtCodigoConsulta(){
		
		return txtCodigoConsulta.getText();
	}

	public void setListadoObsequios(AbstractTableModel abstractTableModel){
		this.tblListaObsequios.setModel(abstractTableModel);
	}
	
	public void mostrarMensaje(String mensaje){
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
	public void limpiarCampos() {
		this.txtCodigoConsulta.setEnabled(true);
		this.txtCodigoConsulta.setText("");
		TableModel tblListaObsequiosModel = 
				new DefaultTableModel(
						new String[][] { { }, { } },
						new String[] { });
		tblListaObsequios.setModel(tblListaObsequiosModel);
	}
	
	public void habilitarCodigo(boolean valor){
		this.txtCodigoConsulta.setEnabled(valor);
	}
	
	
}
